﻿@namespace Blazorise.Docs.Docs.Examples

<UnorderedList>
    <Repeater Items="@items" CollectionChanged="@OnCollectionChanged">
        <UnorderedListItem style="@GetColor( context )">@context</UnorderedListItem>
    </Repeater>
</UnorderedList>

@code{
    System.Collections.ObjectModel.ObservableCollection<int> items { get; } = new( Enumerable.Range( 1, 4 ) );

    Task OnCollectionChanged( System.Collections.Specialized.NotifyCollectionChangedEventArgs eventArgs )
    {
        // do something

        return Task.CompletedTask;
    }

    private static string GetColor( int number )
    {
        const string letters = "0123456789ABCDEF";

        var color = "";

        for ( var i = 0; i < 6; i++ )
        {
            color += letters[( 3 * number + i ) % letters.Length];
        }

        return $"color: #{color}";
    }
}